package com.tunan.common;

import java.util.Map;

import javax.servlet.http.HttpSession;

import com.tunan.persistence.model.PagePermission;
import com.tunan.persistence.model.TSysMenuLink;

public class PagePermissionUtil {

	@SuppressWarnings("unchecked")
	public static PagePermission getPRight(String menuId, HttpSession session) {
		Map<String, TSysMenuLink> rightMap = (Map<String, TSysMenuLink>)session.getAttribute("rightMap");
		PagePermission pRight = new PagePermission();
		if (rightMap != null && rightMap.size()>0) {
			TSysMenuLink right = rightMap.get(menuId);
			if(right != null){
				/*if (null != right.getDefined() && !"".equals(right.getDefined())) {
					String str = right.getDefined();
					String[] defind = str.split(",");
					//pRight.setDefind(defind);
				}*/
				pRight.setDefind(right.getDefined());
				pRight.setRead(Integer.parseInt(right.getR()));
				pRight.setWrite(Integer.parseInt(right.getW()));
			}
		}
		return pRight;
	}
}
